<template>
	<view class="page" style="padding-bottom: 140rpx;">
		<topVue title="补贴额度" name="question-circle" @handle="show=true"></topVue>
		
		<!-- banner部分 -->
		<view class="bannerVue margin0 padding30">
			<view class="flex-between">
				<view class="label">剩余绿色积分补贴总额</view>
				<!-- <view class="key">上限倍数</view> -->
			</view>
			<view class="flex-between align-center margin30">
				<u-count-to
					:start-val="0" 
					:end-val="info.remaining/100"
					font-size="42"
					color="#fff"
					:bold="true"
					separator=","
					decimals="2"
				></u-count-to>
				<!-- <view class="label" style="font-weight: 600;">{{info.upperLimitMultiple}}倍</view> -->
			</view>
			<view class="label margin30">累计已发放补贴总额: {{info.accumulation/100}}绿色积分</view>
		</view>
		
		<!-- 消费补贴 -->
		<view class="box">
			<view class="title">消费补贴</view>
			<view class="progressVue margin20">
			<!-- 	<u-line-progress active-color="#1CC289" inactive-color="#f5f5f5" :striped="true" :striped-active="true" :percent="70"></u-line-progress>
				<view class="flex-between align-center padding-column20">
					<text style="color: #6B7280;">未开始</text>
					<text style="font-weight: 600; color: #6B7280;">共10天</text>
				</view> -->
				<view class="tip">今日消费补贴：{{info.subsidyToday/100}} 绿色积分</view>
				<view class="dataVue flex margin20">
					<view class="w50 flex-column align-center">
						<text style="color: #6B7280;">剩余额度</text>
						<u-gap height="20"></u-gap>
						<text style="font-weight: 600; font-size: 30rpx;">{{info.remainingCredit/100}}</text>
					</view>
					<view class="w50 flex-column align-center">
						<text style="color: #6B7280;">已发放</text>
						<u-gap height="20"></u-gap>
						<text style="font-weight: 600; font-size: 30rpx;">{{info.issued/100}}</text>
					</view>
					<!-- <view class="w33 flex-column align-center">
						<text style="color: #6B7280;">上限倍数</text>
						<u-gap height="20"></u-gap>
						<text style="font-weight: 600; font-size: 30rpx;">{{info.upperLimitMultipleXf}}倍</text> 
					</view> -->
				</view>
			</view>
		</view>
		
		<!-- 推广补贴 -->
		<view class="box">
			<view class="title">分享补贴</view>
			<u-gap height="10"></u-gap>
			<view class="tip">今日分享补贴：{{shareInfo.todaySubsidiesTg/100}} 绿色积分</view>
			<view class="item padding30 margin20">
				<view class="flex-between">
					<view class="name">分享补贴</view>
					<view class="number">{{shareInfo.numberOfPromoters}}人</view>
				</view>
				<view class="descri">奖励积分：{{shareInfo.promotionalRewards/100}}绿色积分</view>
			</view>
			<view class="item padding30 margin20">
				<view class="flex-between align-center">
					<view class="name">服务商补贴</view>
					<view class="level">{{shareInfo.partnerRank}}</view>
				</view>
				<view class="descri" v-if="shareInfo.partnerRank=='普通会员'">0% 团队业绩补贴</view>
				<view class="descri" v-if="shareInfo.partnerRank=='同城服务商'">10% 团队业绩补贴</view>
				<view class="descri" v-if="shareInfo.partnerRank=='区县服务商'">15% 团队业绩补贴</view>
				<view class="descri" v-if="shareInfo.partnerRank=='市级服务商'">20% 团队业绩补贴</view>
				<view class="descri" v-if="shareInfo.partnerRank=='省级服务商'">25% 团队业绩补贴</view>
				<view class="done">已补贴：{{ shareInfo.partnerSubsidy/100 }} 绿色积分</view>
			</view>
			<view class="item padding30 margin20" >
				<view class="flex-between align-center">
					<view class="name">董事补贴</view>
					<view class="number" style="color: #1CC289;">已达标{{ shareInfo.director ? 2 : 0}}个市场</view>
				</view>
				<view class="descri">{{shareInfo.director ? 5 : 0 }}% 新增业绩分红</view>
				<view class="done">已分红：{{shareInfo.directorReward/100}} 绿色积分</view>
			</view>
			<view class="item padding30 margin20">
				<view class="flex-between align-center">
					<view class="name">服务中心补贴</view>
				</view>
				<view class="descri">补贴：{{shareInfo.serviceCenter?3:0}}%</view>
				
				<view class="done">绿色积分补贴：{{shareInfo.serviceCenterReward/100}} 绿色积分</view>
			</view>
		</view>
		
		<view class="botVue flex-between align-center">
			<view class="btn" @click="$tools.route('../index/help')">联系客服</view>
			<view class="btn" @click="$tools.route('./subsidyList')">查看明细</view>
		</view>
		
		<ruleVue :show="show" @cancel="show=false"></ruleVue>
	</view>
</template>

<script>
	import ruleVue from '../../components/rule.vue';
	import { mapState } from "vuex"
	export default {
		components: {
			ruleVue
		},
		data(){
			return {
				show: false,
				info: {},
				shareInfo: {}
			}
		},
		computed: {
			...mapState({
				user: state => state.user,
				balanceInfo: state => state.balanceInfo
			})
		},
		async mounted() {
			await this.getInfo()
			await this.getShareInfo()
		},
		methods: {
			// 消费补贴
			async getInfo(){
				const res = await this.$request("/app-api/pay/wallet-transaction/obtainUserConsumptionSubsidies", 'GET', {
					userId: this.user.id
				})
				if(res.code===0) {
					console.log(res)
					this.info = res.data
					console.log("消费补贴", this.info)
				}
			},
			
			// 推广消费补贴
			async getShareInfo(){
				const res = await this.$request("/app-api/pay/wallet-transaction/obtainUserConsumptionSubsidiesTg", 'GET', {
					userId: this.user.id
				})
				if(res.code===0) {
					console.log(res)
					this.shareInfo = res.data
					console.log("推广消费补贴", this.shareInfo)
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.botVue {
		width: 100%;
		height: 120rpx;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 99;
		padding: 0 30rpx;
		.btn {
			width: 330rpx;
			height: 80rpx;
			border: 1rpx solid #E5E7EB;
			border-radius: 20rpx;
			line-height: 80rpx;
			text-align: center;
			color: #1F2937;
			font-weight: 600;
		}
	}
	.box {
		width: 100%;
		padding: 30rpx;
		.item {
			width: 690rpx;
			background: #F9FAFB;
			border-radius: 12rpx;
			.name {
				font-weight: 700;
				line-height: 1;
			}
			.number {
				color: #4B5563;
				line-height: 1;
			}
			.level {
				width: 180rpx;
				height: 60rpx;
				background: #1CC289;
				border-radius: 22rpx;
				line-height: 60rpx;
				text-align: center;
				color: #fff;
			}
			.descri {
				color: #6B7280;
				line-height: 1;
				padding-top: 30rpx;
			}
			.done {
				color: #6B7280;
				line-height: 1;
				padding-top: 30rpx;
			}
		}
		.title {
			font-size: 30rpx;
			font-weight: 600;
		}
		.tip {
			color: #1CC289;
			padding-top: 10rpx;
			line-height: 1;
		}
		.dataVue {
			width: 690rpx;
			background: #fff;
			border-radius: 12rpx;
			padding: 30rpx;
			box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(178, 178, 178, 0.25), inset 0rpx 8rpx 8rpx 0rpx rgba(255, 255, 255, 0.25);
			text {
				line-height: 1;
			}
		}
	}
	.bannerVue {
		width: 690rpx;
		background: linear-gradient(to right, #1CC289, #60A5FA);
		border-radius: 18rpx;
		.label {
			color: #fff;
		}
		.key {
			color: rgba(255, 255, 255, 0.5);
		}
		.using {
			color: #fff;
			font-weight: 600;
			font-size: 46rpx;
			line-height: 1;
		}
	}
</style>